package com.sl.mes.app.controller;

import com.alibaba.fastjson.JSON;
import com.sl.mes.db.service.MesAdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author mokends
 * @create 2021-11-05  20:24
 */
@SuppressWarnings("all")
@RestController
@RequestMapping("/mes/basedoc")
public class BaseDocController {
    @Autowired
    private MesAdService adService;

    @RequestMapping(value = "/getCustManUserName", method = RequestMethod.GET)
    private Map<String, Object> getusername(){

        HashMap<String, Object> rMap = new HashMap<String, Object>();
        rMap.put("id",2);
        rMap.put("name","小明");
        rMap.put("code","20180806654765");

        return rMap;
    }

    @RequestMapping(value = "getOilType",method = RequestMethod.GET)
    private List<Map<String, Object>> getoilType(){
        String jsonStr = "{\"id\":\"2\",\"name\":\"油品1\",\"code\":\"20180806654765\"}";
        String jsonStr1 = "{\"id\":\"3\",\"name\":\"油品2\",\"code\":\"20180806666665\"}";
        String jsonStr2 = "{\"id\":\"4\",\"name\":\"油品3\",\"code\":\"2018080666446665\"}";
        List<Map<String, Object>> list = new ArrayList<Map<String,Object>>();
        Map map = JSON.parseObject(jsonStr,Map.class);
        Map map1 = JSON.parseObject(jsonStr1,Map.class);
        Map map2 = JSON.parseObject(jsonStr2,Map.class);
        list.add(map);
        list.add(map1);
        list.add(map2);
//        System.out.println("1111");
        System.out.println(map);
        System.out.println(map1);
        System.out.println(map2);
        return list;
    }

    @RequestMapping(value = "getuser",method = RequestMethod.GET)
    private List<Map<String, Object>> getuser(){
        String jsonStr = "{\"id\":\"4\",\"name\":\"张三\",\"code\":\"8888888\"}";

        Map map = JSON.parseObject(jsonStr,Map.class);
        HashMap<String, Object> uMap1 = new HashMap<String, Object>();
        HashMap<String, Object> uMap2 = new HashMap<String, Object>();
        uMap1.put("id",6);
        uMap1.put("name","小刚");
        uMap1.put("code","2018080699999");
        uMap2.put("id",7);
        uMap2.put("name","小余");
        uMap2.put("code","88888899999");


        List<Map<String, Object>> userlist = new ArrayList<Map<String,Object>>();
        userlist.add(map);
        userlist.add(uMap1);
        userlist.add(uMap2);
        System.out.println(userlist);
        return userlist;
    }


    @RequestMapping(value = "getLocation",method = RequestMethod.GET)
    private List<Map<String, Object>> getLocation(){
        HashMap<String, Object> uMap1 = new HashMap<String, Object>();
        HashMap<String, Object> uMap2 = new HashMap<String, Object>();
        HashMap<String, Object> uMap3 = new HashMap<String, Object>();
        uMap1.put("id",2);
        uMap1.put("name","成都库位");
        uMap1.put("code","2222222");
        uMap1.put("total",10000);
        uMap2.put("id",3);
        uMap2.put("name","云南库位");
        uMap2.put("code","4444444");
        uMap2.put("total",5000);
        uMap3.put("id",4);
        uMap3.put("name","湖南库位");
        uMap3.put("code","8666666");
        uMap3.put("total",3000);


        List<Map<String, Object>> locationlist = new ArrayList<Map<String,Object>>();
        locationlist.add(uMap3);
        locationlist.add(uMap1);
        locationlist.add(uMap2);
        System.out.println(locationlist);
        return locationlist;
    }

    @RequestMapping(value = "/getclientname",method = RequestMethod.GET)
    private List<Map<String ,Object>> getclientname(){
        HashMap<String, Object> cMap1 = new HashMap<String, Object>();
        HashMap<String, Object> cMap2 = new HashMap<String, Object>();
        HashMap<String, Object> cMap3 = new HashMap<String, Object>();
        cMap1.put("id",2);
        cMap1.put("name","客户一");
        cMap1.put("code","1001");
        cMap2.put("id",3);
        cMap2.put("name","客户二");
        cMap2.put("code","1002");
        cMap3.put("id",4);
        cMap3.put("name","客户三");
        cMap3.put("code","1003");


        List<Map<String, Object>> clientlist = new ArrayList<Map<String,Object>>();
        clientlist.add(cMap3);
        clientlist.add(cMap2);
        clientlist.add(cMap1);
        System.out.println(clientlist);
        return clientlist;
    }

    @RequestMapping(value = "/buyOilPageInit",method = RequestMethod.GET)
    private Map<String ,Object> buyOilPageInit(){

        HashMap<String, Object> data = new HashMap<String, Object>();

        //1.客户经理
        HashMap<String, Object> cusManager = new HashMap<String, Object>();
        cusManager.put("id","11");
        cusManager.put("code","11");
        cusManager.put("name","小刚");
        data.put("cusManager",cusManager);

        //2.接洽人 Maplist
        //接洽人档案
        List<Map<String, Object>> contactPsnDoc = new ArrayList<Map<String,Object>>();
        //档案中接洽人
        HashMap<String, Object> contactPsn1 = new HashMap<String, Object>();
        contactPsn1.put("id","");
        contactPsn1.put("code","");
        contactPsn1.put("name","选择接洽人");
        contactPsn1.put("id","11");
        contactPsn1.put("code","11");
        contactPsn1.put("name","接洽人小乔");
        contactPsnDoc.add(contactPsn1);
        HashMap<String, Object> contactPsn2 = new HashMap<String, Object>();
        contactPsn2.put("id","22");
        contactPsn2.put("name","接洽人小李");
        contactPsn2.put("code","22");
        contactPsnDoc.add(contactPsn2);
        HashMap<String, Object> contactPsn3 = new HashMap<String, Object>();
        contactPsn3.put("id","33");
        contactPsn3.put("name","接洽人小赵");
        contactPsn3.put("code","33");
        contactPsnDoc.add(contactPsn3);

        HashMap<String, Object> contactPsn = new HashMap<String, Object>();
        contactPsn.put("doc",contactPsnDoc);
        contactPsn.put("seleted",1);
        contactPsn.put("id","11");
        contactPsn.put("name","接洽人小乔");
        data.put("contactPsn",contactPsn); //接洽人

        //3.客户Maplist
        List<Map<String, Object>> customerDoc = new ArrayList<Map<String,Object>>();

        HashMap<String, Object> oncCus1 = new HashMap<String, Object>();
        oncCus1.put("id","11");
        oncCus1.put("name","客户1");
        oncCus1.put("code","11");
        customerDoc.add(oncCus1);

        HashMap<String, Object> oncCus2 = new HashMap<String, Object>();
        oncCus2.put("id","22");
        oncCus2.put("name","客户2");
        oncCus2.put("code","22");
        customerDoc.add(oncCus2);

        HashMap<String, Object> oncCus3 = new HashMap<String, Object>();
        oncCus3.put("id","33");
        oncCus3.put("name","客户3");
        oncCus3.put("code","客户3");
        customerDoc.add(oncCus3);

        HashMap<String, Object> customer = new HashMap<String, Object>();
        customer.put("doc",customerDoc);
        customer.put("seleted",1);
        customer.put("id","11");
        customer.put("name","客户1");
        data.put("customer",customer); //客户

        //4.油品
        List<Map<String, Object>> oilTypeDoc = new ArrayList<Map<String,Object>>();
        HashMap<String, Object> oilTypeMap1 = new HashMap<String, Object>();
        oilTypeMap1.put("id","11");
        oilTypeMap1.put("name","#93油品1");
        oilTypeMap1.put("code","93");
        oilTypeDoc.add(oilTypeMap1);

        HashMap<String, Object> oilTypeMap2 = new HashMap<String, Object>();
        oilTypeMap2.put("id","22");
        oilTypeMap2.put("name","#95油品2");
        oilTypeMap2.put("code","95");
        oilTypeDoc.add(oilTypeMap2);

        HashMap<String, Object> oilTypeMap3 = new HashMap<String, Object>();
        oilTypeMap3.put("id","33");
        oilTypeMap3.put("name","#92油品3");
        oilTypeMap3.put("code","92");
        oilTypeDoc.add(oilTypeMap3);
        HashMap<String, Object> oilType = new HashMap<String, Object>();

        oilType.put("doc",oilTypeDoc);
        oilType.put("seleted",1);
        oilType.put("id","11");
        oilType.put("name","#93油品1");
        data.put("oilType",oilType); //油品

        //5.库位Maplist
        List<Map<String, Object>> whDoc = new ArrayList<Map<String,Object>>();
        HashMap<String, Object> whMap1 = new HashMap<String, Object>();
        whMap1.put("id","11");
        whMap1.put("name","库位1");
        whMap1.put("code","11");
        whDoc.add(whMap1);

        HashMap<String, Object> whMap2 = new HashMap<String, Object>();
        whMap2.put("id","22");
        whMap2.put("name","库位2");
        whMap2.put("code","22");
        whDoc.add(whMap2);

        HashMap<String, Object> whMap3 = new HashMap<String, Object>();
        whMap3.put("id","33");
        whMap3.put("name","库位3");
        whMap3.put("code","33");
        whDoc.add(whMap3);
        HashMap<String, Object> wh = new HashMap<String, Object>();
        wh.put("doc",whDoc);
        wh.put("seleted",1);
        wh.put("id","11");
        wh.put("name","库位1");
        data.put("wh",wh);
        return data;
    }

}
